﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using mtgtoolbox.Controls.CollectionList.ViewModels;
using System.ComponentModel;

namespace mtgtoolbox.ViewModels
{
  class CollectionsViewModel : ICollectionsViewModel, INotifyPropertyChanged 
  {
    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged(string name)
    {
      if (PropertyChanged != null)
        PropertyChanged(this, new PropertyChangedEventArgs(name));
    }


    private ObservableCollection<CollectionMgtViewModel> collections = new ObservableCollection<CollectionMgtViewModel>();
    public ObservableCollection<CollectionMgtViewModel> Collections
    {
      get { return collections; }
    }

    private CollectionMgtViewModel lastAddedItem;
    public CollectionMgtViewModel LastAddedItem
    {
      get { return lastAddedItem; }
      set { lastAddedItem = value; OnPropertyChanged("LastAddedItem"); }
    }

    public void OpenCollection(String collectionName)
    {
      Collections.Add(new CollectionMgtViewModel() { Name = collectionName });
      LastAddedItem = Collections[Collections.Count - 1];
    }
  }
}
